<template>
  <div class="string-box">
    <button @click="reverse">翻转</button>
    <slot></slot>
    <button @click="double">加倍</button>
  </div>
</template>

<script>
  export default {
    props:['value'],
    methods:{
      reverse(){
        const newValue = this.value.split('').reverse().join('');
        //input是自定义事件名称
        this.$emit('input',newValue)
      },
      double(){
        this.$emit('input',this.value+this.value)
      }
    }
  }
</script>

<style lang="sass" scoped>
.string-box
  display: inline-block
  padding: 10px
  border: 1px solid #ccc
</style>
